<template>
  <div id="app">
    <button @click="handleDownloadData">导出</button>
  </div>
</template>
<script>
import { export2Excel } from '@/common/js/util'
export default {
  data() {
    return {
      chart: null,
      tableData: [
          {
            date: "2016-05-02",
            name: "王小虎",
            address: "上海市普陀区金沙江路 1510 弄"
          },
          {
            date: "2016-05-04",
            name: "李小虎",
            address: "上海市普陀区金沙江路 1511 弄"
          },
          {
            date: "2016-05-01",
            name: "孙小虎",
            address: "上海市普陀区金沙江路 1512 弄"
          },
          {
            date: "2016-05-02",
            name: "朱小虎",
            address: "上海市普陀区金沙江路 1513 弄"
          },
          {
            date: "2016-05-04",
            name: "钱小虎",
            address: "上海市普陀区金沙江路 1514 弄"
          },
          {
            date: "2016-05-01",
            name: "杜小虎",
            address: "上海市普陀区金沙江路 1515 弄"
          },
          {
            date: "2016-05-03",
            name: "赵小虎",
            address: "上海市普陀区金沙江路 1516 弄"
          }
        ],
        tableTitleData: [
          {
            title: "日期",
            key: "date"
          },
          {
            title: "姓名",
            key: "name"
          },
          {
            title: "地址",
            key: "address"
          }
        ]
    };
  },
  methods:{
     // 导出的方法
      handleDownloadData() {
        export2Excel(this.tableTitleData,this.tableData)
      },
  },
  created() {
  },
  mounted() {
  },
};
</script>

<style lang="less">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
